<template>
  <van-popup round v-model="show_sub_add" @close="close_pop">
    <div class="form">
      <div class="title">
        <div class="c_flex" style="padding:10px">审核加盟商</div>
      </div>
      <van-form validate-trigger="onSubmit" :label-width="60" validate-first @submit="onSubmit">
        <radio class="padding_img" v-model="user_data.status" :options="[{text:'通过',value:1},{text:'不通过',value:3}]"
          txt_tip="审核状态" />
        <normal_item v-if="user_data.status == 2" v-model="user_data.msg" txt_tip="不通过验证信息" />
        <normal_item v-model="user_data.management_fee" txt_tip="实收管理费" />
        <normal_item v-model="user_data.franchisee_fee" txt_tip="实收加盟费" />
        <normal_item v-model="user_data.bond" txt_tip="实收保证金" />
        <normal_item v-model="user_data.cooperation_sn" txt_tip="合同编号" />
        <time_picker icons="end" v-model="user_data.cooperation_start_date" txt_tip="开始时间" />
        <time_picker icons="end" v-model="user_data.cooperation_end_date" txt_tip="结束时间" />
        <time_picker icons="end" v-model="user_data.sign_date" txt_tip="签约日期" />
        <upload-multi class="padding_img" v-model="user_data.cooperation_images" prop_title="合同照片" />
        <!-- <uploader v-model="user_data.id_card_front" class="set_width_height" text="合同照片" /> -->
        <div class="submit_out c_flex">
          <van-button native-type="submit" class="submit">确定</van-button>
        </div>
      </van-form>
    </div>
  </van-popup>
</template>

<script>
  // import uploader from "@/components/Upload"
  import uploadMulti from '@/components/Upload/multi.vue'
  import normal_item from '@/views/user/component/normal_item'
  import radio from '@/views/user/component/radio'
  import time_picker from '@/components/TimePicker/index.vue';
  import {
    filterObject
  } from '@/utils/validate.js'
  import {
    // RegionService,
    ShoperService
  } from '@/api';
  export default {
    name: 'check',
    props: {
      show_add: Boolean,
      shoper_id: String,
      shoper: {
        type: Object,
        default: () => {}
      }
    },
    components: {
      radio,
      
      uploadMulti,
      // uploader,
      normal_item,
      time_picker
    },
    watch: {
      // show_add(val) {
      //   if (val) {
      //     this.getData()
      //   }
      // },
      shoper: {
        handler(value) {
          // this.$nextTick(() => {
          // debugger;
          if (!this._.isEmpty(value)) {

            this.user_data = filterObject(this.user_data, value);
          }
          console.log('out1', JSON.stringify(value))
          console.log('out', JSON.stringify(this.user_data));
          // })
        },
        immediate: true,
        deep: true
      }
    },
    computed: {
      show_sub_add: {
        get() {
          return this.show_add
        },
        set(value) {
          console.log(value);
          if (!value) {
            this.close_pop();
          }
        }
      }
    },
    mounted() {
      // debugger;
      // this.$nextTick(() => {

      // this.getData();
      // })
      // RegionService.getRegion({
      //   max_leve: 1
      // }).then(res => {
      //   this.regions = res.data;
      // })
    },
    data() {
      return {
        user_data: {
          msg: '',
          bond: '',
          status: '',
          cooperation_sn: '',
          management_fee: '',
          franchisee_fee: '',
          cooperation_start_date: '',
          cooperation_end_date: '',
          sign_date: '',
          cooperation_images: '',
        },
        number_pattern: /^\d+$/
      }
    },

    methods: {
      // getData() {
      //   console.log('excuse');
      //     this.user_data = filterObject(this.user_data, this.shoper);
      //     console.log('user_data: ' + JSON.stringify(this.user_data) );
      // },
      onSubmit() {
        ShoperService.verifyOne(this.user_data, this.shoper_id).then(res => {
          console.log(res)
          this.$EventBus.$emit("update_one")
          if (res.code == 0) {
            this.$message('修改成功！')
          }
          this.close_pop();
        });
      },
      close_pop() {
        // this.empty();
        this.$emit('update:show_add', false);
      },
      // empty() {
      //   this.user_data = this.$options.data().user_data;
      // }
    },
  }
</script>

<style lang="less" scoped>
  .icon_size {
    width: 30px;
    height: 30px;
    margin-right: 15px;
  }


  .form {
    .title {
      width: 50%;
      border-bottom: 1px solid rgba(153, 153, 153, 1);
      margin: 0 auto 15px;
    }

    width:570px;

    .padding_img {
      padding-left: 24px;
      padding-top: 20px;
    }

    .submit_out {
      margin-top: 40px;
      margin-bottom: 30px;
    }

    .submit {

      width: 360px;
      height: 70px;
      border-radius: 37.84px;
      background-color: rgba(235, 95, 17, 1);
      letter-spacing: 1.8px;
      font-size: 28px;
      color: rgba(255, 255, 255, 1);
    }
  }
</style>